<!DOCTYPE html>
<html>

<head>
    <title>Preview Display</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link type="text/css" rel="stylesheet" href="menu/meun.css">
    <style>
        html,
        body {
            padding: 0px;
            margin: 0px;
        }

        body {
            background: #000 url(./assets/兴达八厂/背景兴达.jpg) no-repeat left top;
            background-size: 100%;
        }
    </style>
    <script src='../custom/libs/echarts.js'></script>
    <script src='../libs/core/ht.js'></script>
    <script src='../libs/plugin/ht-vector.js'></script>
    <script src='../conf/dateTime.js'></script>
    <script src='../libs/jquery-3.4.1.min.js'></script>
    <script src='../libs/message.js'></script>
    <script src="../conf/confURL.js"></script>
    <script>
        dataModel = new ht.DataModel();
        graphView = new ht.graph.GraphView(dataModel);
        var url = domain + "/HT_DATA_EIGHT.getGlobalStatistics.do";
        // 基底部门权限
        var deptUrl = domain + getDeptRequest;
        // 八厂 厂区编码
        let deptCodeEight = "XD1112";
        // 九厂 厂区编码
        let deptCodeNine = "XD1113";
        // 总部 编码
        let deptCodeHead = "headQuarters";
        let defaultDeptCode = "";
        var H = [];
        var TH = [];
        var Chart = [];
        var seChart = [];
        var warn = [];
        var Twarn = [];
        let factory5B;
        //let factory2A;
        let factory5A;
        let factory2;
        let factory1;
        let factory8;
        let factory9;
        let factory3;
        var all_1;
        var all_2;
        //let generalFactory;
        //let electricFactory;
        function init() {
            graphView.addToDOM();
            ht.Default.xhrLoad('displays/智慧兴达/兴达八厂/设备监控/device_base.json', function (text) {
                var json = ht.Default.parse(text);
                if (json.title) document.title = json.title;
                dataModel.deserialize(json);
                graphView.fitContent(true);
                tag();
                // 基地权限 获取有权限的部门编码
                getDeptCodeData();
                // 默认展示的报表数据
                get(defaultDeptCode);
                getData7();
                getData8();
                var a = getData9().HT_EQ_ZZ_TREE;
                cd = menu(a)
            });
            //界面时间刷新
            setInterval(function () {
                let dateTime = dataModel.getDataByTag("dateTime")
                let time = updateTime();
                dateTime.a('time', time);
            }, 1000);

            // 基地权限
            function getDeptCodeData() {
                $.ajax({
                    url: deptUrl,
                    type: "POST",
                    headers: request_headers,
                    data: {},
                    async: false,
                    contentType: 'application/x-www-form-urlencoded',
                    success: function (res) {
                        res = JSON.parse(res);
                        if ('OK' === res._MSG_ && Boolean(res.deptCode)) {
                            defaultDeptCode = res.deptCode;
                        }
                    },
                    error: function (error) {
                    }
                });
                return defaultDeptCode;
            }


            //厂区报表切换
            function get(code) {
                    getData1(code),
                    getData2(code);
                    getData3(code);
                    getData4(code);
                    getData5(code);
                    getData6(code);
            };
            graphView.addInteractorListener(function (e) {
                if (e.kind === 'clickData') {
                    // if (e.data._tag == 'generalFactory') {                           
                    //     get("HT_EQ_ZZ_TREE_XDJSXD_XDZB")
                    // }
                    // if (e.data._tag == 'electricFactory') {                           
                    //     get("HT_EQ_ZZ_TREE_XD1204")
                    // }
                    // if (e.data._tag == 'factory1') {                           
                    //     get("HT_EQ_ZZ_TREE_XDJSXD_XD1107")
                    // }
                    // else if (e.data._tag == 'factory2') {
                    //     get("HT_EQ_ZZ_TREE_XDJSXD_XD1108")
                    // }
                    // else if (e.data._tag == 'factory2A') {
                    //     get(code)
                    // }
                    // else if (e.data._tag == 'factory3') {
                    //     get("HT_EQ_ZZ_TREE_XDJSXD_XD1109")
                    // }
                    // else if (e.data._tag == 'factory5A') {
                    //     get(code)
                    // }
                    // else if (e.data._tag == 'factory5B') {
                    //     get(code)
                    // }
                    // else 
                    if (e.data._tag == 'factory8') {
                        get(deptCodeEight);
                    } else if (e.data._tag == 'factory9') {
                        get(deptCodeNine);
                    }else if("base_1" === e.data._tag || "base_21" === e.data._tag){  // 总部
                        get(deptCodeHead);
                    }
                }
            });
        }
        //获取标签
        function tag() {
            all_1 = dataModel.getDataByTag('all_1');
            all_2 = dataModel.getDataByTag('all_2');
            factory5B = dataModel.getDataByTag("factory5B");
            //factory2A = dataModel.getDataByTag("factory2A");
            factory5A = dataModel.getDataByTag("factory5A");
            factory2 = dataModel.getDataByTag("factory2");
            factory1 = dataModel.getDataByTag("factory1");
            factory8 = dataModel.getDataByTag("factory8");
            factory9 = dataModel.getDataByTag("factory9");;
            factory3 = dataModel.getDataByTag("factory3");;
            //generalFactory = dataModel.getDataByTag("generalFactory");
            //electricFactory = dataModel.getDataByTag("electricFactory");
            for (let i = 1; i < 7; i++) {
                H.push(dataModel.getDataByTag("H" + i))
            }
            for (let i = 1; i < 7; i++) {
                TH.push(dataModel.getDataByTag("TH" + i))
            }
            for (let i = 1; i < 5; i++) {
                Chart.push(dataModel.getDataByTag("Chart" + i))
            }
            for (let i = 1; i < 5; i++) {
                seChart.push(dataModel.getDataByTag("seChart" + i))
            }
            for (let i = 1; i < 7; i++) {
                warn.push(dataModel.getDataByTag("warn" + i))
            }
            for (let i = 1; i < 7; i++) {
                Twarn.push(dataModel.getDataByTag("Twarn" + i))
            }
        }
        //八厂设备维修/维护情况接口
        function getData1(code) {
            function err1() {
                warn[0].s("2d.visible", true)
                Twarn[0].s("2d.visible", true)
                pie.s("2d.visible", false)
                sepie.s("2d.visible", false)
            }
            let pie1 = dataModel.getDataByTag("pie1");
            let pie2 = dataModel.getDataByTag("pie2");
            let pie = dataModel.getDataByTag("pie");
            let sepie = dataModel.getDataByTag("sepie");
            let sepie1 = dataModel.getDataByTag("sepie1");
            let sepie2 = dataModel.getDataByTag("sepie2");
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_EQ_JD_REPORT_EQWXWHQKTJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        H[0].a("title", repData.totalTitle);
                        TH[0].a("title", repData.totalTitle);
                        warn[0].s("2d.visible", false);
                        Twarn[0].s("2d.visible", false);
                        pie.s("2d.visible", true);
                        sepie.s("2d.visible", true);
                        pie1.a("name1", repData.data[0].name);
                        pie1.a("name2", repData.data[1].name);
                        pie1.a("name3", repData.data[2].name);
                        pie1.a("value1", repData.data[0].value);
                        pie1.a("value2", repData.data[1].value);
                        pie1.a("value3", repData.data[2].value);
                        sepie1.a("name1", repData.data[0].name);
                        sepie1.a("name2", repData.data[1].name);
                        sepie1.a("name3", repData.data[2].name);
                        sepie1.a("value1", repData.data[0].value);
                        sepie1.a("value2", repData.data[1].value);
                        sepie1.a("value3", repData.data[2].value);
                        pie2.a("name1", repData.data1[0].name);
                        pie2.a("name2", repData.data1[1].name);
                        pie2.a("value1", repData.data1[0].value);
                        pie2.a("value2", repData.data1[1].value);
                        sepie2.a("name1", repData.data1[0].name);
                        sepie2.a("name2", repData.data1[1].name);
                        sepie2.a("value1", repData.data1[0].value);
                        sepie2.a("value2", repData.data1[1].value);
                    } else {
                        err1()
                    }
                },
                error: function (error) {
                    //console.log('err');
                    err1()
                }
            })
            return repData
        }
        //八厂设备故障率接口
        function getData2(code) {
            function err2() {
                warn[1].s("2d.visible", true);
                Twarn[1].s("2d.visible", true);
                Chart[0].s("2d.visible", false);
                seChart[0].s("2d.visible", false);
            }
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_EQ_JD_REPORT_EQGZLTJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        H[1].a("title", repData.totalTitle);
                        TH[1].a("title", repData.totalTitle);;
                        warn[1].s("2d.visible", false);
                        Twarn[1].s("2d.visible", false);
                        Chart[0].s("2d.visible", true);
                        seChart[0].s("2d.visible", true);
                        Chart[0].a("xAxis", repData.data.month);
                        Chart[0].a("yAxis1", repData.data.guzhang);
                        seChart[0].a("xAxis", repData.data.month);
                        seChart[0].a("yAxis1", repData.data.guzhang);
                    } else {
                        err2()
                    }
                },
                error: function (error) {
                    //console.log('err');
                    err2()
                }
            })
            return repData
        }
        //八厂设备综合效率
        function getData3(code) {
            function err3() {
                warn[2].s("2d.visible", true);
                Twarn[2].s("2d.visible", true);
                Chart[1].s("2d.visible", false);
                seChart[1].s("2d.visible", false);
            }
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_EQ_JD_REPORT_EQZHXLOEETJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        H[2].a("title", repData.totalTitle);
                        TH[2].a("title", repData.totalTitle);
                        warn[2].s("2d.visible", false);
                        Twarn[2].s("2d.visible", false);
                        Chart[1].s("2d.visible", true);
                        seChart[1].s("2d.visible", true);;
                        Chart[1].a("xAxis", repData.data.month);
                        Chart[1].a("yAxis", repData.data.xiaolv);
                        seChart[1].a("xAxis", repData.data.month);
                        seChart[1].a("yAxis", repData.data.xiaolv);
                    } else {
                        err3()
                    }
                },
                error: function (error) {
                    //console.log('err');
                    err3()
                }
            })
            return repData
        }
        //八厂设备维修成本接口
        function getData4(code) {
            function err4() {
                warn[3].s("2d.visible", true);
                Twarn[3].s("2d.visible", true);
                shebei.s("2d.visible", false);
                seshebei.s("2d.visible", false);
            }
            var led = [];
            for (let i = 1; i < 4; i++) {
                led.push(dataModel.getDataByTag("led" + i))
            }
            var seled = [];
            for (let i = 1; i < 4; i++) {
                seled.push(dataModel.getDataByTag("seled" + i))
            }
            var text = [];
            for (let i = 1; i < 4; i++) {
                text.push(dataModel.getDataByTag("text" + i))
            }
            var setext = [];
            for (let i = 1; i < 4; i++) {
                setext.push(dataModel.getDataByTag("setext" + i))
            }
            const shebei = dataModel.getDataByTag("shebei")
            const seshebei = dataModel.getDataByTag("seshebei")
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_EQ_JD_REPORT_EQWXCBTJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        H[3].a("title", repData.totalTitle);
                        TH[3].a("title", repData.totalTitle);
                        warn[3].s("2d.visible", false);
                        Twarn[3].s("2d.visible", false);
                        shebei.s("2d.visible", true);
                        seshebei.s("2d.visible", true);
                        for (let i = 0; i < repData.data.title.length; i++) {
                            text[i].s("text", repData.data.title[i]);
                            led[i].a("value", repData.data.value[i]);
                            setext[i].s("text", repData.data.title[i]);
                            seled[i].a("value", repData.data.value[i]);
                        }
                    } else {
                        err4()
                    }
                },
                error: function (error) {
                    //console.log('err');
                    err4()
                }
            })
            return repData
        }
        //八厂故障停台数接口
        function getData5(code) {
            function err5() {
                warn[4].s("2d.visible", true);
                Twarn[4].s("2d.visible", true);
                Chart[2].s("2d.visible", false);
                seChart[2].s("2d.visible", false);
            }
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_EQ_JD_REPORT_GZTTSTJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        H[4].a("title", repData.totalTitle);
                        TH[4].a("title", repData.totalTitle);
                        warn[4].s("2d.visible", false);
                        Twarn[4].s("2d.visible", false);
                        Chart[2].s("2d.visible", true);
                        seChart[2].s("2d.visible", true);
                        Chart[2].a("xAxis", repData.data.month);
                        Chart[2].a("yAxis", repData.data.xiaolv);
                        seChart[2].a("xAxis", repData.data.month);
                        seChart[2].a("yAxis", repData.data.xiaolv);
                    } else {
                        err5()
                    }
                },
                error: function (error) {
                    //console.log('err');
                    err5()
                }
            })
            return repData
        }
        //八厂吨平报修统计接口
        function getData6(code) {
            function err6() {
                warn[5].s("2d.visible", true);
                Twarn[5].s("2d.visible", true);
                Chart[3].s("2d.visible", false);
                seChart[3].s("2d.visible", false);
            }
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_EQ_JD_REPORT_DPNHTJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible == "true") {
                        H[5].a("title", repData.totalTitle);
                        TH[5].a("title", repData.totalTitle);
                        warn[5].s("2d.visible", false);
                        Twarn[5].s("2d.visible", false);
                        Chart[3].s("2d.visible", true);
                        seChart[3].s("2d.visible", true);
                        Chart[3].a("xAxis", repData.data.month);
                        Chart[3].a("yAxis1", repData.data.dunpingbaoxiu);
                        Chart[3].a("yAxis2", repData.data.biaozhun);
                        Chart[3].a("yAxis3", repData.data.chanliang);
                        Chart[3].a("yAxis4", repData.data.baoxiucishu);
                        seChart[3].a("xAxis", repData.data.month);
                        seChart[3].a("yAxis1", repData.data.dunpingbaoxiu);
                        seChart[3].a("yAxis2", repData.data.biaozhun);
                        seChart[3].a("yAxis3", repData.data.chanliang);
                        seChart[3].a("yAxis4", repData.data.baoxiucishu);
                    } else {
                        err6()
                    }
                },
                error: function (error) {
                    //console.log('err');
                    err6()
                }
            })
            return repData
        }
        //厂区上的跳转链接接口
        function getData7() {
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_EQ_ZZ_MAPTAB"
                },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.HT_EQ_ZZ_MAPTAB.visible == "true") {
                        factory1.s("label", repData.HT_EQ_ZZ_MAPTAB.urlMap);
                        factory5B.s("label", repData.HT_EQ_ZZ_MAPTAB.urlMap);
                        //factory2A.s("label", repData.HT_EQ_ZZ_MAPTAB.urlMap);
                        factory5A.s("label", repData.HT_EQ_ZZ_MAPTAB.urlMap);
                        factory2.s("label", repData.HT_EQ_ZZ_MAPTAB.urlMap);
                        factory8.s("label", repData.HT_EQ_ZZ_MAPTAB.urlMap);
                        factory9.s("label", repData.HT_EQ_ZZ_MAPTAB.urlMap);
                        factory3.s("label", repData.HT_EQ_ZZ_MAPTAB.urlMap);
                    }
                },
                error: function (error) {
                    //  console.log('err');
                }
            });
        }
        //返回按钮接口
        function getData8() {
            const backButton = dataModel.getDataByTag("backButton")
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: { props: "HT_EQ_JD_BUTTON_RETURN" },
                headers: request_headers,
                async: true,
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.HT_EQ_JD_BUTTON_RETURN.visible == "true") {
                        repData = JSON.parse(res);
                        backButton.a("url", repData.HT_EQ_JD_BUTTON_RETURN.data.url);
                        backButton.s("2d.visible", repData.HT_EQ_JD_BUTTON_RETURN.visible);
                    }
                },
                error: function (error) {
                    //console.log('err');
                }
            })
            return repData
        }
        //菜单接口
        function getData9() {
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_EQ_ZZ_TREE"
                },
                headers: request_headers,
                async: false,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res, handleJson);
                    if (repData._MSG_ === 'OK' && repData.visible == true) {
                        document.getElementById("node").style.display = "block"
                    } else {
                        document.getElementById("node").style.display = "none"
                    }
                },
                error: function (error) {
                    document.getElementById("node").style.display = "none"
                }
            });
            return  repData
        }
    </script>
</head>
<body onload='setTimeout(init, 300)'>
    <div id="ct">
        <div id="abc" style="display:none;height: 100%;width: 95%">
            <div id="app"
                style="background:url(menu/tree3.png) no-repeat; background-size:100% 100%;position: absolute;z-index:20; width: 11%; height:85%;top:11%;overflow: hidden;">
                <span id="total" style="font-size:18px";>兴达公司</span>
                <img class="lin" src="menu/line.png">
                </br></br></br></br>
            </div>
        </div>
        <div id="node"
            style="left:0px;display:block;background-color:rgba(red, green, blue, 0);position:absolute;width: 33px;height: 650px;top: 80px;z-index: 100;">
        </div>
    </div>
</body>

</html>